package com.egao.common.manage.school;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.core.web.PageParam;
import com.egao.common.core.web.PageResult;
import com.egao.common.module.student.entity.vo.StudentSignAdminListVO;
import com.egao.common.module.student.service.StudentSignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lym
 * @date 2023/6/1 9:35
 */
@Api(tags = "校毕业去向查询")
@RestController
@RequestMapping("${api}")
public class SchoolSignQueryController extends BaseController {

    @Autowired
    private StudentSignService studentSignService;

    private final String title = "校毕业去向查询";

    @PreAuthorize("hasAuthority('school:sign:query')")
    @OperLog(value = title, desc = "分页查询毕业去向")
    @ApiOperation(value = "分页查询毕业去向")
    @ApiPageParam
    @GetMapping("/school/sign/query/page")
    public PageResult<StudentSignAdminListVO> page(HttpServletRequest request) {
        PageParam<StudentSignAdminListVO> pageParam = new PageParam<>(request);
        pageParam.put("category", "0");
        return studentSignService.listAdminPage(pageParam);
    }

    @PreAuthorize("hasAuthority('school:sign:query')")
    @OperLog(value = title, desc = "查询详情")
    @ApiOperation("查询详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", required = true, dataType = "Integer")
    })
    @GetMapping("/school/sign/query/detail")
    public JsonResult detail(Integer id) {
        return studentSignService.detail(id, null, false, getLoginUser().getUserType());
    }

}
